var app = getApp();
const { infoArr } = require("../../utils/cityInfo");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    url: '',
    type: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
    this.setData({
        PrivacyAuthorization: app.globalData.PrivacyAuthorization
    })
    this.setData({
      url: 'https://hb.offcn.com/zg/xhszixun/zixun.html',
    })
    if ((options.fx != undefined) && (options.id != undefined)) {
        if (options.fx.length >= 0) {
            links = await app.methods.getLink(options.id)
            options.type = links.type ? links.type : ''
            options.kf = links.kf ? links.kf : ''
            options.fenxiao = options.fx ? options.fx : ''
            options.gonghao = options.gh ? options.gh : ''
        }
    }
    if (options.scene != undefined) {
        if (options.scene.length > 0) {
            var links, str = '';
            let jxOptions;
            options.scene = options.scene.replace(/%253D/g, ".");
            options.scene = options.scene.replace(/%2526/g, "-");
            jxOptions = await app.methods.getOPtions(options)
            links = await app.methods.getLink(jxOptions.id)
            options.type = links.type ? links.type : ''
            options.kf = links.kf ? links.kf : ''
            options.fenxiao = jxOptions.fx ? jxOptions.fx : ''
            options.gonghao = jxOptions.gh ? jxOptions.gh : ''
        }
    }
    this.setData({
        options: options
    })
    console.log(options)
    const { QrCode } = app.globalData;
    console.log(QrCode)
    let qwqdm = null;
    if(QrCode && QrCode.indexOf('jl.offcn.com') == -1) {
      qwqdm = QrCode;
    } else {
      let { kf } = options;
      console.log(kf)
      qwqdm = kf;
      if (kf == '1badbffb0db94dcdaaae5e91d560d11b') {
        let res = await app.methods.noFenxiao(infoArr);
        qwqdm = res.qwqdm
      } else if (kf == '21612f0dc200456cacb59d0a4b0f2748') {
        qwqdm = infoArr[0].qwqdm
      } else if (kf == '111ec7fbfe894c39bb74902e38cf4918') {
        qwqdm = infoArr[1].qwqdm
      } else if (kf == '9d5bd3c156d343838bdd4642269c181f') {
        qwqdm = infoArr[3].qwqdm
      } else if (kf == '1aec3c39b366458ab0dd7e976721a08e') {
        qwqdm = infoArr[4].qwqdm
      } else if (kf == '27c5aa647c334ece97967cb62ff219a1') {
        qwqdm = infoArr[6].qwqdm
      } else if (kf == '57735c436d234e5a8be3f12bfcab3560') {
        qwqdm = infoArr[7].qwqdm
      } else if (kf == 'f61d81046d9947f8a9a22bb8b662c25a') {
        qwqdm = infoArr[8].qwqdm
      } else if (kf == '35c31c0091cb48f7900d53200c8ede8a') {
        qwqdm = infoArr[5].qwqdm
      } else if (kf == 'ec49e595ac654efe93739fdf1b0f9d7c') {
        qwqdm = infoArr[9].qwqdm
      } else if (kf == '742457f6de7349c38cb386029c2be3e7') {
        qwqdm = infoArr[10].qwqdm
      } else if (kf == '75d233b81eb14956b992603a1f5530c6') {
        qwqdm = infoArr[2].qwqdm
      }
    }
    console.log(qwqdm)
    this.setData({
      kf: qwqdm,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
  // if(this.data._id) {
  //   return {
  //     title: "河北公职考试专业分类查询_河北中公教育",
  //     path: "/pages/database/database?_id="+this.data._id + '&gonghao=' + this.data.gonghao + '&fenxiao=' + this.data.fenxiao,
  //     success: function (t) {
  //       console.log(t, "转发成功");
  //     },
  //     fail: function (t) {
  //       console.log(t, "转发失败");
  //     }
  //   }
  // }
  // }
})